package com.skyline.jfs.common.logger;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

/**
 * 日志类
 * 
 * <pre>
 * 使用方法： 
 * if({@link LoggerFactory#isDebugEnabled()}) {
 * 	{@link LoggerFactory#getLogger()#debug(messahe)}
 * }
 * </pre>
 * 
 * @author wuqh
 */
public class LoggerFactory {
	private static Logger SysMsgLogger = Logger.getLogger("SYS");
	// public static Logger ErrMsgLogger = Logger.getLogger("ERR");

	static {
		PropertyConfigurator.configure(LoggerFactory.class
				.getResource("/config/logger/log4j.properties"));
	}

	/**
	 * 获取日志记录器
	 */
	public static Logger getLogger() {
		return SysMsgLogger;
	}

	/**
	 * 级别debug可以？TRUE：FALSE
	 */
	public static boolean isDebugEnabled() {
		return SysMsgLogger.isDebugEnabled();
	}

	/**
	 * 级别info可以？TRUE：FALSE
	 */
	public static boolean isInfoEnabled() {
		return SysMsgLogger.isInfoEnabled();
	}

	/**
	 * 级别warn可以？TRUE：FALSE
	 */
	public static boolean isWarnEnabled() {
		return SysMsgLogger.isEnabledFor(Level.WARN);
	}

	/**
	 * 级别error可以？TRUE：FALSE
	 */
	public static boolean isErrorEnabled() {
		return SysMsgLogger.isEnabledFor(Level.ERROR);
	}

	/**
	 * 可以trace堆栈？TRUE：FALSE
	 */
	public static boolean isTraceEnabled() {
		return SysMsgLogger.isTraceEnabled();
	}

}
